//
//  WofabudeTableViewCell.m
//  XRSquare
//
//  Created by UaenaMo on 2018/8/15.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "WofabudeTableViewCell.h"

@interface WofabudeTableViewCell ()
{
    UILabel * titleLabel;
    UILabel * priceLabel;
    UILabel * timeLabel;
    UILabel * dayLabel;
    UILabel * statusLabel;
    UIView * labels;
}
@end

@implementation WofabudeTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth, 20)];
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:titleLabel];
        
        priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth - 20, 20)];
        priceLabel.textAlignment = NSTextAlignmentRight;
        priceLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:priceLabel];
        
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, ScreenWidth, 20)];
        timeLabel.font = [UIFont systemFontOfSize:12];
        timeLabel.textColor = [UIColor colorFromHexCode:@"b3b3b3"];
        [self addSubview:timeLabel];
        
        dayLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, ScreenWidth, 20)];
        dayLabel.font = [UIFont systemFontOfSize:12];
        dayLabel.textColor = [UIColor colorFromHexCode:@"b3b3b3"];
        [self addSubview:dayLabel];
        
        statusLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 40, ScreenWidth - 20, 20)];
        statusLabel.font = [UIFont systemFontOfSize:15];
        statusLabel.textAlignment = NSTextAlignmentRight;
        statusLabel.textColor = [UIColor colorFromHexCode:@"b3b3b3"];
        [self addSubview:statusLabel];
        
        labels = [[UIView alloc]initWithFrame:CGRectMake(10, 70, ScreenWidth, 20)];
        [self addSubview:labels];

        UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 99, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
    }
    return self;
}

+(CGFloat)height
{
    return 100;
}

-(void)loadData:(NSDictionary *)data int:(int)intt other:(int)other
{
    if (intt == 3)
    {
        titleLabel.text = [data objectForKey:@"TaskTitle"];
    }
    else
    {
        titleLabel.text = [data objectForKey:@"TaskClassName"];
    }
    priceLabel.text = [data objectForKey:@"TaskPrice"];
    timeLabel.text = [NSString stringWithFormat:@"%@ - %@",[data objectForKey:@"TaskBeginTime"],[data objectForKey:@"TaskEndTime"]];
    if (intt == 3) {
        dayLabel.text = [NSString stringWithFormat:@"报名截止时间：%@",[data objectForKey:@"TaskBeginTime"]];
    }
    else
    {
        NSMutableString * st = [[NSMutableString alloc]initWithString:@""];
        if ([[data objectForKey:@"TaskWeekday1"]isEqualToNumber:@1])
        {
            [st appendString:@"周一 "];
        }
        if ([[data objectForKey:@"TaskWeekday2"]isEqualToNumber:@1])
        {
            [st appendString:@"周二 "];
        }
        if ([[data objectForKey:@"TaskWeekday3"]isEqualToNumber:@1])
        {
            [st appendString:@"周三 "];
        }
        if ([[data objectForKey:@"TaskWeekday4"]isEqualToNumber:@1])
        {
            [st appendString:@"周四 "];
        }
        if ([[data objectForKey:@"TaskWeekday5"]isEqualToNumber:@1])
        {
            [st appendString:@"周五 "];
        }
        if ([[data objectForKey:@"TaskWeekday6"]isEqualToNumber:@1])
        {
            [st appendString:@"周六 "];
        }
        if ([[data objectForKey:@"TaskWeekday7"]isEqualToNumber:@1])
        {
            [st appendString:@"周日 "];
        }
        dayLabel.text = st;
    }
    // button 们
    if (other == 1) {
        statusLabel.text = [NSString stringWithFormat:@"已报名(%@)",[data objectForKey:@"TaskEnrollNum"]];
        [labels removeFromSuperview];
        labels = [[UIView alloc]initWithFrame:CGRectMake(10, 70, ScreenWidth, 20)];
        [self addSubview:labels];
        if (intt == 1)
        {
            CGFloat lenght = 0;
            {
                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                label.text = [data objectForKey:@"TaskShowType"];
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskOnOffShelf"]isEqualToNumber:@0])
                {
                    label.text = @"上架中";
                }
                else
                {
                    label.text = @"已下架";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskUnEvaluate"]isEqualToNumber:@0])
                {
                    label.text = @"已评价";
                }
                else
                {
                    label.text = @"待评价";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskUnAgree"]isEqualToNumber:@0])
                {
                    label.text = @"已确认";
                }
                else
                {
                    label.text = @"待确认";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskDead"]isEqualToNumber:@1])
                {
                    label.text = @"无效";
                }
                else
                {
                    label.text = @"有效";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
        }
        else if (intt == 2)
        {
            CGFloat lenght = 0;
            {
                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                label.text = [data objectForKey:@"TaskShowType"];
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskOnOffShelf"]isEqualToNumber:@0])
                {
                    label.text = @"上架中";
                }
                else
                {
                    label.text = @"已下架";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskUnEvaluate"]isEqualToNumber:@0])
                {
                    label.text = @"已评价";
                }
                else
                {
                    label.text = @"待评价";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskUnAgree"]isEqualToNumber:@0])
                {
                    label.text = @"已确认";
                }
                else
                {
                    label.text = @"待确认";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskDead"]isEqualToNumber:@1])
                {
                    label.text = @"无效";
                }
                else
                {
                    label.text = @"有效";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
        }
        else
        {
            CGFloat lenght = 0;
            {
                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[NSString stringWithFormat:@"%@",[data objectForKey:@"TaskShowType"]]isEqualToString:@"0"])
                {
                    label.text = @"仅自己可见";
                }
                if ([[NSString stringWithFormat:@"%@",[data objectForKey:@"TaskShowType"]]isEqualToString:@"1"])
                {
                    label.text = @"仅好友可见";
                }
                if ([[NSString stringWithFormat:@"%@",[data objectForKey:@"TaskShowType"]]isEqualToString:@"2"])
                {
                    label.text = @"全部可见";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskOnOffShelf"]isEqualToNumber:@1])
                {
                    label.text = @"上架中";
                }
                else
                {
                    label.text = @"已下架";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskCanBaoMing"]isEqualToNumber:@0])
                {
                    label.text = @"开启报名";
                }
                else
                {
                    label.text = @"关闭报名";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskOffShelfSee"]isEqualToNumber:@0])
                {
                    label.text = @"过期不可见";
                }
                else
                {
                    label.text = @"过期可见";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
            {

                UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(lenght, 0, 30, 20)];
                label.layer.borderColor = [UIColor colorFromHexCode:@"f3f3f3"].CGColor;
                label.layer.borderWidth = 1;
                label.font = [UIFont systemFontOfSize:12];
                if ([[data objectForKey:@"TaskDead"]isEqualToNumber:@1])
                {
                    label.text = @"过期";
                }
                else
                {
                    label.text = @"未过期";
                }
                label.textAlignment = NSTextAlignmentCenter;
                [label sizeToFit];
                label.frame = CGRectMake(lenght, 0, label.frame.size.width + 5, 20);
                [labels addSubview:label];
                lenght += label.frame.size.width + 5;
            }
        }

    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
